<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="format-detection" content="telephone=no" />
		<meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
		<script src="../../script/mui.min.js"></script>
		<script src="../../script/jquery.min.js"></script>
		<link rel="stylesheet" href="../../css/mui.min.css" />
		<link rel="stylesheet" href="../../css/CFNetPP_Base.css">
		<link rel="stylesheet" type="text/css" href="../../css/weui.min.css">
		<link rel="stylesheet" href="../../css/base.css"/>
		<link rel="stylesheet" href="../../css/exam.css">
		<title>自由课程测验考试章节页</title>
		<script src="../../script/jquery.min.js" type="text/javascript"></script>
		<script type="text/javascript" charset="utf-8">
			mui.init();
		</script>
	</head>
	<body >
		<div class="stu-test" id="scroll">
			<div class="base_style_color" id='BarAppearance' style="height: 22px;width: 100%; position:fixed; left: 0px;top:0px;z-index: 998" ></div>
			<div class="base_navigation_bar base_style_color base_navigation_item_bar" style="position: fixed;left: 0px;top: 20px;">
				<div class="base_navigation_bar base_style_color base_navigation_item_bar">
					<a class="base_left_item" href="#" onclick="backTestToast()"> <img class="base_back_icon" src="../../image/icon_jiantou.png" alt=""> </a>
					<span id="title"></span>
					<a class="base_right_item top_0" href="#popover-card"> 答题卡</a>
					<a class="base_right_item " id="describe"  onclick="openBewrite()" style="display: none;"> 描述</a>
				</div>
			</div>
			<div class="ReviewWeekly_div  " style="margin-top: 64px"></div>
			<div class="space10"></div>
			<div class="k-con-border qusetion-type" >
				<div class="k-con-part" style="position: static">
					<p class="k-text-center k-c323 k-f12">
						<span class="test-score-detail "> 试卷分数：<span class="k-cred" id="score"></span>分 </span>
						<span class="test-score-detail"> 通过分数：<span class="k-cred" id="passscore"></span>分 </span>
						<span class="test-score-detail"> 考试时间：<span class="k-cred" id="kstime"></span>分 </span>
					</p>
				</div>
			</div>
			<!--	<div class="k-con-border qusetion-type ">
			<div class="k-con-part clearfix test-num-bar">
			<p class="left k-c323 k-f16">
			<span id="itemType"> </span>
			</p>
			<p class="right k-c323 ">
			<span class="k-f16" id="questionNum"> 1 </span>
			<!--<span class="k-f14 k-cgray" id="questionLength"></span>-->
			<!--</p>-->
			<!--</div>-->
			<!--</div>-->
			<div class="k-con test-m-bottom70 test-analysis">
				<div class="mui-slider">
					<div class="mui-slider-group" ></div>
				</div>
			</div>
			<div class="k-con1 k-text-center k-fixed-bottom test-bottom1" id="sub_div">
				<div class="k-con-part1" id='sub_bt'>
					<button type="button" class="mui-btn mui-btn-primary" onclick="CheckSubmit()">
						交卷
					</button>
					<div class="remainingtime">
						<span> 倒计时 </span>
						<span id="kaoShiTime" class="k-cred"></span>
					</div>
				</div>
				<div class="k-con-part" id='score_bt' style="display: none;">
					<span class="test-score-detail"> 你的分数：<span class="k-cred" id="your_score" ></span>分 </span>
				</div>
			</div>
			<div id="popover-card" class="mui-popover test-num-card" style=" height:150px; ">
				<div class="mui-scroll-wrapper">
					<div class="mui-scroll" id="scroll-card"></div>
				</div>
			</div>
		</div>
		<div id="offlineAlert" class="weui_dialog_confirm" style="display: none;">
			<div class="weui_mask"></div>
			<div class="weui_dialog">
				<div class="weui_dialog_hd">
					<strong class="weui_dialog_title" id="checkNum"></strong>
				</div>
				<div class="weui_dialog_bd"></div>
				<div class="weui_dialog_ft">
					<a onclick="cleanCancel()" href="#" class="weui_btn_dialog default"  style="color:#18b4ed">取消</a>
					<a onclick="cleanConfirm()" href="#" class="weui_btn_dialog primary"  style="color:#18b4ed">确定</a>
				</div>
			</div>
		</div>
		<div class="weui_dialog_alert" id="closeAlert" style="display: none;">
			<div class="weui_mask"></div>
			<div class="weui_dialog">
				<div class="weui_dialog_hd">
					<strong class="weui_dialog_title" id="checkNum2"></strong>
				</div>
				<div class="weui_dialog_ft">
					<a onclick="Cancel()" href="#" class="weui_btn_dialog primary"  style="color:#18b4ed">确定</a>
				</div>
			</div>
		</div>
		<div id="LookAlert" class="weui_dialog_confirm" style="display: none;">
			<div class="weui_mask"></div>
			<div class="weui_dialog">
				<div class="weui_dialog_hd">
					<strong class="weui_dialog_title" id="tilte_look"></strong>
				</div>
				<div class="weui_dialog_bd"></div>
				<div class="weui_dialog_ft">
					<a onclick="lookno()" href="#" class="weui_btn_dialog default">取消</a>
					<a onclick="lookyes()" href="#" class="weui_btn_dialog primary"  style="color:#18b4ed">确定</a>
				</div>
			</div>
		</div>
		<div id="AgainTestAlert" class="weui_dialog_confirm" style="display: none;">
			<div class="weui_mask"></div>
			<div class="weui_dialog">
				<div class="weui_dialog_hd">
					<strong class="weui_dialog_title" id="tilte_AgainTest"></strong>
				</div>
				<div class="weui_dialog_bd"></div>
				<div class="weui_dialog_ft">
					<a onclick="AgainTest_no()" href="#" class="weui_btn_dialog default">取消</a>
					<a onclick="AgainTest_yes()" href="#" class="weui_btn_dialog primary"  style="color:#18b4ed">确定</a>
				</div>
			</div>
		</div>
	</body>
	<script type="text/javascript" src="../../script/api.js"></script>
	<script src="../../script/jquery.min.js" type="text/javascript"></script>
	<script type="text/javascript" src="../../script/MD5.js"></script>
	<script src="../../script/common.js"></script>
	<script type="text/javascript" src="../../script/requestTool.js"></script>
	<script type="text/javascript">
		var daan = new Object();
		var questionLen = '';
		//题目名称数组
		var itemNameArr = new Array();
		//题目id数组
		var itemIdArr = new Array();
		var qidArr = new Array();
		var clickNum = "";
		var pid = "";
		// 计划id
		var cid = "";
		//课程id
		var chapterid = "";
		//章节id
		var tid = "";
		var stime = "";
		var timeNum = "";
		var passScore = "";
		apiready = function() {
			scrollUI();
			//开启加载框
			showProgress();
			// 滚动监听
			listenScroll();
			//获取数据
			loadData();
			//按钮返回提示
			kebackListen();
			// 当前试题数
			currentQuestionNum();
			//tab页高度
			tabHeight();
		}
		function daojishi() {
			var t = setInterval(function() {
				if (timeNum > 0) {
					timeNum--;
					var currentTime = sZhuanHms(timeNum);
					x = document.getElementById("kaoShiTime");
					//查找元素
					x.innerHTML = currentTime;
				} else {
					clearTimeout(t);
					api.toast({
						msg : '答题时间已到正在为您交卷'
					});
					DeleteAnswerNullData();
					SubmitData();
				}
			}, 1000);
		}

		//删除未回答的题目数组
		function DeleteAnswerNullData() {
			for (var k = 0; k < qidArr.length; k++) {
				if (daan[qidArr[k]] == null || daan[qidArr[k]] == "") {
					delete daan[qidArr[k]];
				}
			}
		}

		function loadData() {
			//			var testUrl = "http://base.cfnet.org.cn/index.php/exam/exam_admin/getExamById?uid=" + $api.getStorage('cfnetppuid') + "&jid=" + $api.getStorage('cfnetppjid') + "&pid=0&examid=" + api.pageParam.examid;
			var testUrl = 'http://base.cfnet.org.cn/index.php/exam/exam_admin/getExamById?pid=0&examid=20160726093703&uid=34868&jid=158';
			cfnetppPOST(testUrl, '', false, function(data, status) {
				//				alert(JSON.stringify(data));
				hideProgress();
				if (status == 'success') {
					if (data.code == 200) {
						var list = data.json;
						if (list != null) {
							var examlist = list.examlist;
							if (examlist != null && examlist != '') {
								tid = examlist.eid;
								$('#score').text(examlist.paper_qscore);
								$('#passscore').text(examlist.efen);
								$('#kstime').text(examlist.dtime);
								timeNum = parseInt(examlist.dtime)
								var listArr = GetHtmlTestScoreList(JSON.parse((examlist.etimu)));
								if (timeNum != null && timeNum != '') {
									daojishi();
								}
							} else {
								back('考试题目为空');
								clickNum = 3;
							}
						} else {
							back('考试题目为空');
							clickNum = 3;
						}
					} else if (data.code == 116) {
						back('考试次数达到上限');
						clickNum = 3;
					} else if (data.code == 111) {
						back('测验已过期');
						clickNum = 3;
					} else if (data.code == 110) {
						back('测验未开始');
						clickNum = 3;
					} else {
						back('数据异常');
						clickNum = 3;
					}
				} else {
					api.toast({
						msg : '网络异常',
						duration : 2000,
						location : 'bottom'
					});
				}
			});
		}

		// 滚动监听
		function listenScroll() {
			var winHeight = $(window).height();
			//获取当前页面高度
			$(window).resize(function() {
				var thisHeight = $(this).height();
				if (winHeight - thisHeight > 50) {
					//当软键盘弹出，在这里面操作
					$("#sub_div").css('display', 'none');
				} else {
					$("#sub_div").css('display', 'block');
					//当软键盘收起，在此处操作
				}
			});
			var maxHeight = $(".ReviewWeekly_div").height() + 10;
			var testResultHeight = $(".test-result").height() + 10;
			$(window).on("touchstart", function() {
				var activeHeight = $('.mui-slider-group').children(".mui-active").height();
				if (api.systemType == 'android') {
					if (activeHeight > 420) {
						//					alert(activeHeight);
						$(".mui-slider").css({
							"height" : activeHeight
						}, {
							"overflow" : "scroll"
						})
					} else if (activeHeight < 420) {
						$(".mui-slider").css({
							"height" : 500
						}, {
							"overflow" : "auto"
						})
					}
				} else {
					$(".mui-slider").css({
						"height" : activeHeight
					}, {
						"overflow" : "scroll"
					})
				}
			});
		}

		// 当前试题数
		function currentQuestionNum() {
			document.querySelector('.mui-slider').addEventListener('slide', function(event) {
				//注意slideNumber是从0开始的；
				document.getElementById("questionNum").innerText = event.detail.slideNumber + 1;
				document.getElementById("itemType").innerText = itemNameArr[event.detail.slideNumber];
				//				alert(event.detail.slideNumber);
				//				GetAnswerData(event.detail.slideNumber);
			});
		}

		function tabHeight() {
			document.querySelector('.mui-slider').addEventListener('slide', function(event) {
				var activeHeight = $(".test-qusetions .mui-active").height();
				$(".mui-slider").css({
					"height" : activeHeight
				}, {
					"overflow" : "auto"
				})
			});
		}

		function setUpObject(data) {
			var questions = data;
			for (var i = 0; i < questions.length; i++) {
				var question = questions[i];
				qidArr.push(question.qid);
				//子问题数组
				//子问题数组
				if (question.qtype == '1' || question.qtype == '3' || question.qtype == '8') {//单选题
					//取出子题目
					daan[question.qid] = new String();
				} else if (question.qtype == '2' || question.qtype == '7' || question.qtype == '9') {//多选题识图题
					//取出子题目
					daan[question.qid] = new Array();
				} else if (question.qtype == '4' || question.qtype == '10') {//论述题
					//取出子题目
					daan[question.qid] = new Array();
				}
			}
		}

		//删除未回答的题目数组
		function DeleteAnswerNullData() {
			for (var k = 0; k < qidArr.length; k++) {
				if (daan[qidArr[k]] == null || daan[qidArr[k]] == "") {
					delete daan[qidArr[k]];
				}
			}
		}

		//考试页代码拼接
		function SetTestExamUI(list) {
			var qxuan = '';
			var data = list;
			setUpObject(data);
			questionLen = data.length;
			for (var i = 0; i < questionLen; i++) {
				if (data[i] != null && data[i] != '') {
					itemNameArr.push(ByIdGetQuestionTypeName(data[i].qtype));
					itemIdArr.push(data[i].qid);
					$('#itemType').text(itemNameArr[0]);
					qxuan = JSON.parse(data[i].qxuanxiang);
					$(".mui-slider-group").append('<div class="mui-slider-item" id="item' + (i + 1) + '" itemtype="' + data[i].qtype + '"></div>')
					if (data[i].qtype == 1 || data[i].qtype == 3 || data[i].qtype == 8) {
						$("#item" + (i + 1)).append('<div class="k-con-part3 clearfix">' + '<span id="itemType" class="k-f18">' + ByIdGetQuestionTypeName(data[i].qtype) + '</span>' + '<p class="k-f16 k-c323 k-mt5 indent-5">' + (i + 1) + "、" + "(" + data[i].score + "分 " + ")" + htmlspecialchars_decode(data[i].questions) + '</p>' + '<div class="test-answer-list left_10" onclick="GetAnswerData(' + i + ')" itemtype="' + data[i].qtype + '">' + '</div>' + '</div>')
						//	是单选或判断
						for (var k = 0; k < qxuan.length; k++) {
							var danxuanStr = "";
							if (qxuan[k].xuanzhe.toString().indexOf("img") > 0) {
								danxuanStr = qxuan[k].xuanzhe;
							} else {
								danxuanStr = htmlspecialchars_decode(qxuan[k].xuanzhe);
							}
							$("#item" + (i + 1) + " .test-answer-list").append('<div class="mui-input-row mui-radio mui-left " >' + '<label>' + danxuanStr + '</label>' + '<input  Itemindex="' + i + '" dataindex="' + (k + 1) + '" name="radio' + data[i].qid + '" type="radio"   itemid="' + data[i].qid + '">' + '</div> ')
						}
					} else if (data[i].qtype == 2) {
						//						$("#item" + (i + 1)).append('<div class="k-con-part clearfix">' + '<p class="k-f16 k-c323 k-mt15">' + (i + 1) + "、" + htmlspecialchars_decode(data[i].questions) + '</p>' + '<div class="test-answer-list" onclick="GetAnswerData(' + i + ')"   itemtype="' + data[i].qtype + '">' + '</div>' + '</div>')
						$("#item" + (i + 1)).append('<div class="k-con-part3 clearfix">' + '<span id="itemType" class="k-f18">' + ByIdGetQuestionTypeName(data[i].qtype) + '</span>' + '<p class="k-f16 k-c323 k-mt5 indent-5">' + (i + 1) + "、" + "(" + data[i].score + "分 " + ")" + htmlspecialchars_decode(data[i].questions) + '</p>' + '<div class="test-answer-list left_10" onclick="GetAnswerData(' + i + ')" itemtype="' + data[i].qtype + '">' + '</div>' + '</div>')
						//	是多选
						for (var k = 0; k < qxuan.length; k++) {
							if (qxuan[k].xuanzhe.toString().indexOf("img") > 0) {
								$("#item" + (i + 1) + " .test-answer-list").append('<div class="mui-input-row mui-checkbox mui-left" >' + '<label>' + qxuan[k].xuanzhe + '</label>' + '<input   Itemindex="' + i + '" dataindex="' + (k + 1) + '" name="checkbox1" value="Item 1" type="checkbox"  itemid="' + data[i].qid + '">' + '</div>')
							} else {
								$("#item" + (i + 1) + " .test-answer-list").append('<div class="mui-input-row mui-checkbox mui-left" >' + '<label>' + htmlspecialchars_decode(qxuan[k].xuanzhe) + '</label>' + '<input Itemindex="' + i + '"   dataindex="' + (k + 1) + '" name="checkbox1" value="Item 1" type="checkbox"  itemid="' + data[i].qid + '">' + '</div>')
							}
						}
					} else if (data[i].qtype == 4 || data[i].qtype == 10) {
						// 论述
						//						$("#item" + (i + 1)).append('<div class="k-con-part clearfix">' + '<p class="k-f16 k-c323 k-mt15">' + (i + 1) + "、" + htmlspecialchars_decode(data[i].questions) + '</p>' + '<div class="test-answer-list" onclick="GetAnswerData(' + i + ')"   itemtype="' + data[i].qtype + '">' + '</div>' + '</div>')
						$("#item" + (i + 1)).append('<div class="k-con-part3 clearfix">' + '<span id="itemType" class="k-f18">' + ByIdGetQuestionTypeName(data[i].qtype) + '</span>' + '<p class="k-f16 k-c323 k-mt5 indent-5">' + (i + 1) + "、" + "(" + data[i].score + "分 " + ")" + htmlspecialchars_decode(data[i].questions) + '</p>' + '<div class="test-answer-list left_10" onclick="GetAnswerData(' + i + ')" itemtype="' + data[i].qtype + '">' + '</div>' + '</div>')
						$("#item" + (i + 1) + " .test-answer-list").append('<div class="test-answer-list">' + '<textarea Itemindex="' + i + '" class="k-texttarea k-f14" id="content" itemid="' + data[i].qid + '"></textarea>' + '</div>')
					} else if (data[i].qtype == 7) {//识图题
						var questionStr = "";
						if (data[i].questions.indexOf("img") > 0) {
							questionStr = data[i].questions;
							//							$("#item" + (i + 1)).append('<div class="k-con-part clearfix">' + '<p class="k-f16 k-c323 k-mt15">' + (i + 1) + "、" + data[i].questions + '</p>' + '<div class="test-answer-list"  onclick="GetAnswerData(' + i + ')">' + '</div>' + '</div>')
						} else {
							questionStr = htmlspecialchars_decode(data[i].questions);
							//							$("#item" + (i + 1)).append('<div class="k-con-part clearfix">' + '<p class="k-f16 k-c323 k-mt15">' + (i + 1) + "、" + htmlspecialchars_decode(data[i].questions) + '</p>' + '<div class="test-answer-list"  onclick="GetAnswerData(' + i + ')"  itemtype="' + data[i].qtype + '">' + '</div>' + '</div>')
						}
						$("#item" + (i + 1)).append('<div class="k-con-part3 clearfix">' + '<span id="itemType" class="k-f18">' + ByIdGetQuestionTypeName(data[i].qtype) + '</span>' + '<p class="k-f16 k-c323 k-mt5 indent-5">' + (i + 1) + "、" + "(" + data[i].score + "分 " + ")" + questionStr + '</p>' + '<div class="test-answer-list left_10" onclick="GetAnswerData(' + i + ')" itemtype="' + data[i].qtype + '">' + '</div>' + '</div>')
						for (var k = 0; k < qxuan.length; k++) {
							if (qxuan[k].xuanzhe.indexOf("img") > 0) {
								$("#item" + (i + 1) + " .test-answer-list").append('<div class="mui-input-row mui-checkbox mui-left" >' + '<label>' + qxuan[k].xuanzhe + '</label>' + '<input Itemindex="' + i + '"  dataindex="' + (k + 1) + '" name="checkbox1" value="Item 1" type="checkbox"  itemid="' + data[i].qid + '">' + '</div>')
							} else {
								$("#item" + (i + 1) + " .test-answer-list").append('<div class="mui-input-row mui-checkbox mui-left" >' + '<label>' + htmlspecialchars_decode(qxuan[k].xuanzhe) + '</label>' + '<input  Itemindex="' + i + '" dataindex="' + (k + 1) + '" name="checkbox1" value="Item 1" type="checkbox"  itemid="' + data[i].qid + '">' + '</div>')
							}
						}
					} else if (data[i].qtype == 9) {//视频题
						if (data[i].questions.indexOf("script") > 0) {
							var str = data[i].questions.match(/<p .*?url=\"(.+?)\"/)[1];
							//							$("#item" + (i + 1)).append('<div class="k-con-part clearfix">' + '<p class="k-f16 k-c323 k-mt15">' + (i + 1) + "、" + htmlspecialchars_decode(data[i].questions) + '</p>' + '<p>' + '<video width="90%" height="240" controls="controls"><source src=" ' + str + '" type="video/mp4"/></video>' + '</p>' + '<div class="test-answer-list" onclick="GetAnswerData(' + i + ')"  itemtype="' + data[i].qtype + '">' + '</div>' + '</div>')
							$("#item" + (i + 1)).append('<div class="k-con-part3 clearfix">' + '<span id="itemType" class="k-f18">' + ByIdGetQuestionTypeName(data[i].qtype) + '</span>' + '<p class="k-f16 k-c323 k-mt5 indent-5">' + (i + 1) + "、" + "(" + data[i].score + "分 " + ")" + htmlspecialchars_decode(data[i].questions) + '</p>' + '<p>' + '<video width="90%" height="240" controls="controls"><source src=" ' + str + '" type="video/mp4"/></video>' + '</p>' + '<div class="test-answer-list" onclick="GetAnswerData(' + i + ')"  itemtype="' + data[i].qtype + '">' + '</div>' + '</div>')
							//	是多选
							for (var k = 0; k < qxuan.length; k++) {
								$("#item" + (i + 1) + " .test-answer-list").append('<div class="mui-input-row mui-checkbox mui-left" >' + '<label>' + qxuan[k].xuanzhe + '</label>' + '<input Itemindex="' + i + '" dataindex="' + (k + 1) + '" name="checkbox1" value="Item 1" type="checkbox"  itemid="' + data[i].qid + '">' + '</div>')
							}
						} else {
							//							$("#item" + (i + 1)).append('<div class="k-con-part clearfix">' + '<p class="k-f16 k-c323 k-mt15">' + (i + 1) + "、" + data[i].questions + '</p>' + '<div class="test-answer-list" onclick="GetAnswerData(' + i + ')"  itemtype="' + data[i].qtype + '">' + '</div>' + '</div>')
							$("#item" + (i + 1)).append('<div class="k-con-part3 clearfix">' + '<span id="itemType" class="k-f18">' + ByIdGetQuestionTypeName(data[i].qtype) + '</span>' + '<p class="k-f16 k-c323 k-mt5 indent-5">' + (i + 1) + "、" + "(" + data[i].score + "分 " + ")" + htmlspecialchars_decode(data[i].questions) + '</p>' + '<div class="test-answer-list left_10" onclick="GetAnswerData(' + i + ')" itemtype="' + data[i].qtype + '">' + '</div>' + '</div>')
							//	是多选
							for (var k = 0; k < qxuan.length; k++) {
								if (qxuan[k].xuanzhe.indexOf("script") > 0) {
									var str2 = qxuan[k].xuanzhe.match(/<p .*?url=\"(.+?)\"/)[1];
									$("#item" + (i + 1) + " .test-answer-list").append('<div class="mui-input-row mui-checkbox mui-left" >' + '<label>' + '<p>' + '<video width="90%" height="240" controls="controls"><source src=" ' + str2 + '" type="video/mp4"/></video>' + '</p>' + '</label>' + '<input Itemindex="' + i + '" dataindex="' + (k + 1) + '" name="checkbox1" value="Item 1" type="checkbox"  itemid="' + data[i].qid + '">' + '</div>')
								} else {
									$("#item" + (i + 1) + " .test-answer-list").append('<div class="mui-input-row mui-checkbox mui-left" >' + '<label>' + htmlspecialchars_decode(qxuan[k].xuanzhe) + '</label>' + '<input Itemindex="' + i + '" dataindex="' + (k + 1) + '" name="checkbox1" value="Item 1" type="checkbox"  itemid="' + data[i].qid + '">' + '</div>')
								}
							}
						}
					}
				} else {
					$('#itemType').text(itemNameArr[0]);
					$(".mui-slider-group").append('<div class="mui-slider-item" id="item' + (i + 1) + '"  ></div>')
					$("#item" + (i + 1)).append('<div class="k-con-part clearfix tont" >' + '<p class="k-f16 k-c323 k-mt15">' + (i + 1) + "、" + '本题为空' + '</p>' + '<div  class="test-answer-list"      onclick="GetAnswerData(' + i + ')" >' + '</div>' + '</div>')
				}
				$(".mui-slider-item  img").width("90%");
				$(".mui-input-row  img").height(100);
			}
			var gallery = mui('.mui-slider');
			gallery.slider({
				interval : 0//自动轮播周期，若为0则不自动播放，默认为0；
			});
			//	生成答题卡题号
			popoverCardNum(questionLen);
			//  试题总数
			allQuestionNum(questionLen);
			// 点击答题卡切换
			$("#popover-card span").on("click", function() {
				gallery.slider().gotoItem($(this).index())
				mui('#popover-card').popover('hide')
			});
		}

		//得到答案数据
		function GetAnswerData(slideNumber) {
			var duooptionid = '';
			//多选题选项id
			var danoptionid = '';
			//单选题选项id
			var duoQuestionid = '';
			//多选题题目id
			var danQuestionid = '';
			var duoObject = new Object();
			//单选题tiid
			var lunshuQuestionid = "";
			var Itemindex = '';
			//论述题id
			var duoQuestionidArr = new Array();
			var lunshuContent = '';
			var itemtype = $(".mui-slider-group").children().eq(slideNumber).attr('itemtype');
			//获取题目类型
			if (itemtype == '1' || itemtype == '2' || itemtype == '3') {//单选题,多选题,判断题
				$(".mui-slider-group").children().eq(slideNumber).find('input').each(function(i) {
					if ($(this).attr('type') === 'radio') {
						if (this.checked == true) {
							danoptionid = $(this).attr('dataindex');
							Itemindex = $(this).attr('Itemindex');
							$("#scroll-card").find("span").eq(Itemindex).removeClass('qusetion-num').addClass('qusetion-selected');
							danQuestionid = $(this).attr('itemid');
							daan[danQuestionid] = danoptionid;
						}
					} else if ($(this).attr('type') === 'checkbox') {
						if (this.checked == true) {
							duooptionid = $(this).attr('dataindex');
							Itemindex = $(this).attr('Itemindex');
							$("#scroll-card").find("span").eq(Itemindex).removeClass('qusetion-num').addClass('qusetion-selected');
							duoQuestionid = $(this).attr('itemid');
							duoObject[duooptionid] = "1";
							daan[duoQuestionid] = duoObject;
						} else {
							var index = duoQuestionidArr.indexOf($(this).attr('dataindex'));
							if (index > -1) {
								duoQuestionidArr.splice(index, 1);
							}
						}
					}
				});
			} else {
				$(".mui-slider-group").children().eq(slideNumber).find('textarea').on('input', function() {
					lunshuQuestionid = $(this).attr('itemid');
					//				//论述题内容
					lunshuContent = $(this).val();
					Itemindex = $(this).attr('Itemindex');
					if (lunshuContent != null && lunshuContent != '') {
						$("#scroll-card").find("span").eq(Itemindex).removeClass('qusetion-num').addClass('qusetion-selected');
					}
					daan[lunshuQuestionid] = lunshuContent;
				});
			}
		}

		//检查题目是否提交
		function CheckSubmit() {
			DeleteAnswerNullData();
			var daanLen = ObjectCount(daan);
			var strLen = questionLen - daanLen;
			if (strLen == 0) {
				$("#checkNum").text("是否确定提交？");
			} else {
				$("#checkNum").text("您还有" + strLen + "道题未提交,是否确定提交?");
			}
			$('#offlineAlert').show();
			clickNum = 1;
		}

		function kebackListen() {
			api.addEventListener({
				name : 'keyback'
			}, function(ret, err) {
				//coding...
				backTestToast();
			});
		}

		//退出考试提示
		function backTestToast() {
			if (clickNum == 3) {
				api.closeWin({
				});
			} else {
				$("#checkNum").text("是否确定退出考试?");
				$('#offlineAlert').show();
				clickNum = 2;
			}
		}

		//退出考试提示
		function back(str) {
			$('#sub_bt').hide();
			$("#checkNum2").text(str);
			$('#closeAlert').show();
		}

		function Cancel() {
			$('#closeAlert').hide();
			backClick();
		}

		function cleanCancel() {
			$('#offlineAlert').hide();
		}

		//确定
		function cleanConfirm() {
			$('#offlineAlert').hide();
			if (clickNum == 1) {
				showProgress();
				var itemLength = itemNameArr.length;
				SubmitData();
			} else if (clickNum == 2) {
				backClick();
			}
		}

		//提交答题数据
		function SubmitData() {
			var timestamp = (Date.parse(new Date())) / 1000;
			var param = {
				tid : tid, //测验id
				pid : api.pageParam.pid, //计划id
				cid : api.pageParam.cid, //课程id
				vid : '', //章节id
				uid : $api.getStorage('cfnetppuid'), //用户id
				jid : $api.getStorage('cfnetppjxid'), //集团id
				stime : timestamp, //开始答测验时间（时间戳）
				answer : daan
			};
			//			alert(JSON.stringify(param));
			cfnetppPOST(url_subtest, param, false, function(data, status) {
				//				alert(JSON.stringify(data));
				hideProgress();
				if (status == 'success') {
					if (data.code == 200) {
						ShowToast('提交成功');
						sendNotifi();
					} else {
						//
						api.toast({
							msg : '提交失败',
							duration : 2000,
							location : 'bottom'
						});
					}
				} else {
					api.toast({
						msg : '提交失败',
						duration : 2000,
						location : 'bottom'
					});
				}
			});
		}

		function AgainTest_no() {
			$('#AgainTestAlert').hide();
			api.closeWin({
			});
		}

		function AgainTest_yes() {
			$('#AgainTestAlert').hide();
			var y = 0;
			var h = api.winHeight - y;
			api.openWin({useWKWebView:true,
				name : 'New_student_study_freecourse_TestExam',
				url : 'New_student_study_freecourse_TestExam.html',
				rect : {
					x : 0,
					y : y,
					w : 'auto',
					h : h,
				},
				pageParam : {
					pid : api.pageParam.pid,
					cid : api.pageParam.cid,
					chapterid : api.pageParam.chapterid,
					rid : api.pageParam.rid,
				},
				reload : true
			});
		}

		function lookyes() {
			$('#LookAlert').hide();
			openTestScore();
		}

		function lookno() {
			$('#LookAlert').hide();
			api.closeWin({
			});
		}

		function sendNotifi() {
			api.sendEvent({
				name : 'RefreshTestNotifi'
			});
		}

		//		//打开测验结果页
		function openTestScore() {
			var y = 0;
			var h = api.winHeight - y;
			api.openWin({useWKWebView:true,
				name : 'New_student_study_freecourse_TestScore',
				url : 'New_student_study_freecourse_TestScore.html',
				rect : {
					x : 0,
					y : y,
					w : 'auto',
					h : h,
				},
				pageParam : {
					pid : api.pageParam.pid,
					cid : api.pageParam.cid,
					chapterid : api.pageParam.chapterid,
					rid : api.pageParam.rid,
					title : api.pageParam.title,
					bewrite : $api.getStorage('bewrite'),
					is_dis_bewrite : $api.getStorage('is_dis_bewrite'),
				},
				bounces : false,
				vScrollBarEnabled : true,
				hScrollBarEnabled : false
			});
		}

		//  试题总数
		function allQuestionNum(questionLen) {
			$("#questionLength").text("/" + questionLen)
		}

		//	生成答题卡题号
		function popoverCardNum(questionLen) {
			for (var i = 0; i < questionLen; i++)
				$("#scroll-card").append('<span class="qusetion-num">' + (i + 1) + '</span>')
		}
	</script>
</html>